home *** CD-ROM | disk | FTP | other *** search
-
- package sub_arctic.constraints;
-
- import sub_arctic.lib.interactor_consts;
- import sub_arctic.lib.interactor;
- import sub_arctic.lib.manager;
- import sub_arctic.lib.sub_arctic_error;
-
- import java.awt.Point;
- import java.util.Vector;
-
- /** This class provides an external constraint that executes one of the
- * standard constraint functions based on a (partial) standard constraint
- * encoding along with an explicit set of operands (which involve explicitly
- * provided objects and standard or non-standard parts).
- */
- public class std_ext_constraint extends external_constraint {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Partial encoding of the constraint. This controls how the constraint
- * operates and is encoded the same way as a standard constraint encoding
- * (see std_encoding_consts) except that the encoded operands and constant
- * are ignored.
- */
- protected int _encoding = std_constraint_consts.NO_CONSTRAINT.encoding();
-
- /** Partial encoding of the constraint. This controls how the constraint
- * operates and is encoded the same way as a standard constraint encoding
- * (see std_encoding_consts) except that the encoded operands and constant
- * are ignored.
- */
- public int encoding() {return _encoding;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Constant value passed to the constraint evaluation function. */
- protected int _const_value = 0;
-
- /** Constant value passed to the constraint evaluation function. */
- public int const_value() {return _const_value;}
-
- /** Set the constant value passed to the constraint evaluation function. */
- public void set_const_value(int v)
- {
- _const_value = v;
-
- /* mark our selves out of date */
- value_ood(0, null, 0);
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Orientation under which this constraint is evaluated. This should match
- * the orientation of the object to which this constraint is attached and
- * only affects implicit operands (i.e., self.wh used in centered()), and
- * does not affect explicit operands which maintain their own orientation.
- * This should have one of the values HORIZONTAL, VERTICAL, or NOT_ORIENTED.
- */
- protected byte _orientation;
-
- /** Orientation under which this constraint is evaluated. This should match
- * the orientation of the object to which this constraint is attached and
- * only affects implicit operands (i.e., self.wh used in centered()), and
- * does not affect explicit operands which maintain their own orientation.
- * This should have one of the values HORIZONTAL, VERTICAL, or NOT_ORIENTED.
- */
- public byte orientation() {return _orientation;}
-
- /** Set the orientation under which this constraint is evaluated. This
- * should match the orientation of the object to which this constraint is
- * attached and only affects implicit operands (i.e., self.wh used in
- * centered()), and does not affect explicit operands which maintain their
- * own orientation. This should have one of the values HORIZONTAL, VERTICAL,
- * or NOT_ORIENTED.
- */
- public void set_orientation(int ov) {_orientation = (byte)ov;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** The object which serves as self for the constraint. This object should
- * be the one that contains the part being constrained and controls the
- * coordinate system in which position values are delivered. */
- protected interactor _self_obj = null;
-
- /** The object which serves as self for the constraint. This object should
- * be the one that contains the part being constrained and controls the
- * coordinate system in which position values are delivered. */
- public interactor self_obj() {return _self_obj;}
-
- /** Set the object which serves as self for the constraint. This object
- * should be the one that contains the part being constrained and controls
- * the coordinate system in which position values are delivered. */
- public void set_self_obj(interactor slf_obj) {_self_obj = slf_obj;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Flag value for non-standard part code. This can be stored in
- * op*_std_part to indicate that a non-standard part is being referred to
- * (in which case op*_part will contain the part number being referenced). */
- public static final byte NOT_STANDARD = (byte)0xff;
-
- /** Bit mask for bit used to indicate a horizontally oriented standard part.
- * This bit will be set in op*_std_part if the part is to be interpreted
- * as having a horizontal orientation.
- */
- public static final byte IS_HORIZ = (byte)0x40;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Standard part code for operand 1. If this has the special value
- * NOT_STANDARD, then a non-standard part (found in _op1_part) is used
- * instead. Otherwise this will contain a standard part code (one of the
- * PARTCODE_* values) optionally ORed with IS_HORIZ to indicate that it
- * should be interpreted with a horizontal orientation. */
- protected byte _op1_std_part = NOT_STANDARD;
-
- /** Standard part code for operand 1. If this has the special value
- * NOT_STANDARD, then a non-standard part (found in _op1_part) is used
- * instead. Otherwise this will contain a standard part code (one of the
- * PARTCODE_* values) optionally ORed with IS_HORIZ to indicate that it
- * should be interpreted with a horizontal orientation. */
- public byte op1_std_part() {return _op1_std_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Standard part code for operand 2. If this has the special value
- * NOT_STANDARD, then a non-standard part (found in _op2_part) is used
- * instead. Otherwise this will contain a standard part code (one of the
- * PARTCODE_* values) optionally ORed with IS_HORIZ to indicate that it
- * should be interpreted with a horizontal orientation. */
- protected byte _op2_std_part = NOT_STANDARD;
-
- /** Standard part code for operand 2. If this has the special value
- * NOT_STANDARD, then a non-standard part (found in _op2_part) is used
- * instead. Otherwise this will contain a standard part code (one of the
- * PARTCODE_* values) optionally ORed with IS_HORIZ to indicate that it
- * should be interpreted with a horizontal orientation. */
- public byte op2_std_part() {return _op2_std_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Standard part code for operand 3. If this has the special value
- * NOT_STANDARD, then a non-standard part (found in _op3_part) is used
- * instead. Otherwise this will contain a standard part code (one of the
- * PARTCODE_* values) optionally ORed with IS_HORIZ to indicate that it
- * should be interpreted with a horizontal orientation. */
- protected byte _op3_std_part = NOT_STANDARD;
-
- /** Standard part code for operand 3. If this has the special value
- * NOT_STANDARD, then a non-standard part (found in _op3_part) is used
- * instead. Otherwise this will contain a standard part code (one of the
- * PARTCODE_* values) optionally ORed with IS_HORIZ to indicate that it
- * should be interpreted with a horizontal orientation. */
- public byte op3_std_part() {return _op3_std_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Non-standard part number for operand 1 of the constraint. This is used
- * if op1_std_part == NON_STANDARD, and will contain the part number of
- * the part providing operand 1. */
- protected int _op1_part;
-
- /** Non-standard part number for operand 1 of the constraint. This is used
- * if op1_std_part == NON_STANDARD, and will contain the part number of
- * the part providing operand 1. */
- public int op1_part() {return _op1_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Object referenced by operand 1 of the constraint. */
- protected interactor _op1_obj = null;
-
- /** Object referenced by operand 1 of the constraint. */
- public interactor op1_obj() {return _op1_obj;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Non-standard part number for operand 2 of the constraint. This is used
- * if op2_std_part == NON_STANDARD, and will contain the part number of
- * the part providing operand 2. */
- protected int _op2_part;
-
- /** Non-standard part number for operand 2 of the constraint. This is used
- * if op2_std_part == NON_STANDARD, and will contain the part number of
- * the part providing operand 2. */
- public int op2_part() {return _op2_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Object referenced by operand 2 of the constraint. */
- protected interactor _op2_obj = null;
-
- /** Object referenced by operand 2 of the constraint. */
- public interactor op2_obj() {return _op2_obj;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Non-standard part number for operand 3 of the constraint. This is used
- * if op3_std_part == NON_STANDARD, and will contain the part number of
- * the part providing operand 3. */
- protected int _op3_part;
-
- /** Non-standard part number for operand 3 of the constraint. This is used
- * if op3_std_part == NON_STANDARD, and will contain the part number of
- * the part providing operand 3. */
- public int op3_part() {return _op3_part;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Object referenced by operand 3 of the constraint. */
- protected interactor _op3_obj = null;
-
- /** Object referenced by operand 3 of the constraint. */
- public interactor op3_obj() {return _op3_obj;}
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Cache of number of operands for the encoded function */
- protected int _num_ops = 0;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Construct a 3 operand external constraint that executes the constraint
- * function encoded in standard from, but with arbitrary operand values.<p>
- *
- * @param int enc The (partial) standard encoding for the
- * constraint (the operand encoding portions are
- * ignored).
- * @param interactor slf_obj The object which acts as self for the
- * constraint (this is only used for constraints
- * that implicitly reference self or parent).
- * @param int orient Orientation of the part we are constraining.
- * @param ext_objpart_encoding op1 An encoding of the first operand.
- * @param ext_objpart_encoding op2 An encoding of the second operand.
- * @param ext_objpart_encoding op3 An encoding of the third operand.
- * @param int c_val The constant value supplied to the constraint.
- */
- public std_ext_constraint(
- int enc,
- interactor slf_obj,
- int orient,
- ext_objpart_encoding op1,
- ext_objpart_encoding op2,
- ext_objpart_encoding op3,
- int c_val)
- {
- /* verify that we have a 3 operand function */
- _num_ops = std_constraint_impl.the_impl().num_ops(enc);
- if (_num_ops != 3)
- throw new sub_arctic_error("Encoding for " +
- std_constraint_impl.the_impl().opcode_str(enc) +
- " cannot be used with 3 operands");
-
- /* save encoding, self and constant */
- _encoding = enc;
- _self_obj = slf_obj;
- _orientation = (byte)orient;
- _const_value = c_val;
-
- /* record all the operand parts */
- if (op1.uses_std_part())
- {
- _op1_std_part = (byte)op1.ref_part();
- if (op1.orientation() == std_encoding_consts.HORIZONTAL)
- _op1_std_part |= IS_HORIZ;
- }
- else
- {
- _op1_std_part = NOT_STANDARD;
- _op1_part = op1.ref_part();
- }
-
- if (op2.uses_std_part())
- {
- _op2_std_part = (byte)op2.ref_part();
- if (op2.orientation() == std_encoding_consts.HORIZONTAL)
- _op2_std_part |= IS_HORIZ;
- }
- else
- {
- _op2_std_part = NOT_STANDARD;
- _op2_part = op2.ref_part();
- }
-
- if (op3.uses_std_part())
- {
- _op3_std_part = (byte)op3.ref_part();
- if (op3.orientation() == std_encoding_consts.HORIZONTAL)
- _op3_std_part |= IS_HORIZ;
- }
- else
- {
- _op3_std_part = NOT_STANDARD;
- _op3_part = op3.ref_part();
- }
-
- /* record all the operand objects */
- _op1_obj = op1.ref_obj();
- _op2_obj = op2.ref_obj();
- _op3_obj = op3.ref_obj();
-
- /* establish dependency edges */
- setup_dependencies();
-
- }
-
- //had:
- //* @exception bad_value if the encoding does not represent a 3 operand
- //* function.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Construct a 2 operand external constraint that executes the constraint
- * function encoded in standard from, but with potentially arbitrary
- * operand values.<p>
- *
- * @param int enc The (partial) standard encoding for the
- * constraint (the operand encoding portions are
- * ignored).
- * @param interactor slf_obj The object which acts as self for the
- * constraint (this is only used for constraints
- * that implicitly reference self or parent).
- * @param int orient Orientation of the part we are constraining.
- * @param ext_objpart_encoding op1 An encoding of the first operand.
- * @param ext_objpart_encoding op2 An encoding of the second operand.
- * @param int c_val The constant value supplied to the constraint.
- */
- public std_ext_constraint(
- int enc,
- interactor slf_obj,
- int orient,
- ext_objpart_encoding op1,
- ext_objpart_encoding op2,
- int c_val)
- {
- /* verify that we have a 2 operand function */
- _num_ops = std_constraint_impl.the_impl().num_ops(enc);
- if (_num_ops != 2)
- throw new sub_arctic_error("Encoding for " +
- std_constraint_impl.the_impl().opcode_str(enc) +
- " cannot be used with 2 operands");
-
- /* save encoding, self and constant */
- _encoding = enc;
- _self_obj = slf_obj;
- _orientation = (byte)orient;
- _const_value = c_val;
-
- /* record all the operand parts */
- if (op1.uses_std_part())
- {
- _op1_std_part = (byte)op1.ref_part();
- if (op1.orientation() == std_encoding_consts.HORIZONTAL)
- _op1_std_part |= IS_HORIZ;
- }
- else
- {
- _op1_std_part = NOT_STANDARD;
- _op1_part = op1.ref_part();
- }
-
- if (op2.uses_std_part())
- {
- _op2_std_part = (byte)op2.ref_part();
- if (op2.orientation() == std_encoding_consts.HORIZONTAL)
- _op2_std_part |= IS_HORIZ;
- }
- else
- {
- _op2_std_part = NOT_STANDARD;
- _op2_part = op2.ref_part();
- }
-
- /* record all the operand objects */
- _op1_obj = op1.ref_obj();
- _op2_obj = op2.ref_obj();
-
- /* establish dependency edges */
- setup_dependencies();
-
- }
-
- //had:
- //* @exception bad_value if the encoding does not represent a 2 operand
- //* function.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Construct a 1 operand external constraint that executes the constraint
- * function encoded in standard from, but with a potentially arbitrary
- * operand value.<p>
- *
- * @param int enc The (partial) standard encoding for the
- * constraint (the operand encoding portions are
- * ignored).
- * @param interactor slf_obj The object which acts as self for the
- * constraint (this is only used for constraints
- * that implicitly reference self or parent).
- * @param int orient Orientation of the part we are constraining.
- * @param ext_objpart_encoding op1 An encoding of the second operand.
- * @param int c_val The constant value supplied to the constraint.
- */
- public std_ext_constraint(
- int enc,
- interactor slf_obj,
- int orient,
- ext_objpart_encoding op1,
- int c_val)
- {
- /* verify that we have a 1 operand function */
- _num_ops = std_constraint_impl.the_impl().num_ops(enc);
- if (_num_ops != 1)
- throw new sub_arctic_error("Encoding for " +
- std_constraint_impl.the_impl().opcode_str(enc) +
- " cannot be used with 1 operand");
-
- /* save encoding, self and constant */
- _encoding = enc;
- _self_obj = slf_obj;
- _orientation = (byte)orient;
- _const_value = c_val;
-
- /* record operand part */
- if (op1.uses_std_part())
- {
- _op1_std_part = (byte)op1.ref_part();
- if (op1.orientation() == std_encoding_consts.HORIZONTAL)
- _op1_std_part |= IS_HORIZ;
- }
- else
- {
- _op1_std_part = NOT_STANDARD;
- _op1_part = op1.ref_part();
- }
-
- /* record operand object */
- _op1_obj = op1.ref_obj();
-
- /* establish dependency edges */
- setup_dependencies();
-
- }
-
- //had:
- //* @exception bad_value if the encoding does not represent a 1 operand
- //* function.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Construct a 0 operand external constraint that executes the constraint
- * function encoded in standard from.<p>
- *
- * @param int enc The (partial) standard encoding for the
- * constraint (the operand encoding portions are
- * ignored).
- * @param interactor slf_obj The object which acts as self for the
- * constraint (this is only used for constraints
- * that implicitly reference self or parent).
- * @param int orient Orientation of the part we are constraining.
- * @param int c_val The constant value supplied to the constraint.
- */
- public std_ext_constraint(
- int enc,
- interactor slf_obj,
- int orient,
- int c_val)
- {
- /* verify that we have a 0 operand function */
- _num_ops = std_constraint_impl.the_impl().num_ops(enc);
- if (_num_ops != 0)
- throw new sub_arctic_error("Encoding for " +
- std_constraint_impl.the_impl().opcode_str(enc) +
- " cannot be used with 0 operands");
-
- /* save encoding, self and constant */
- _encoding = enc;
- _self_obj = slf_obj;
- _orientation = (byte)orient;
- _const_value = c_val;
-
- /* establish dependency edges */
- setup_dependencies();
-
- }
-
- //had:
- //* @exception bad_value if the encoding does not represent a 0 operand
- //* function.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Establish the external dependencies for a particular standard part
- * reference.<p>
- * @param interactor for_obj the object depended upon.
- * @param byte part_code the code of the part within that object we are
- * dependent upon. Note: this should include the
- * IS_HORIZ bit as used in op*_std_part.
- */
- protected void setup_std_part_dependencies(interactor for_obj, byte part_code)
- {
- boolean horiz;
- byte code;
-
- horiz = (part_code & IS_HORIZ) != 0;
- code = (byte)(part_code & ~IS_HORIZ & 0xff);
-
- switch(code)
- {
- case std_encoding_consts.PARTCODE_XY:
- if (horiz)
- for_obj.attach_dependent(interactor_consts.X, this , 0);
- else
- for_obj.attach_dependent(interactor_consts.Y, this , 0);
- break;
-
- case std_encoding_consts.PARTCODE_XY2:
- case std_encoding_consts.PARTCODE_CENTER:
- if (horiz)
- {
- for_obj.attach_dependent(interactor_consts.X, this , 0);
- for_obj.attach_dependent(interactor_consts.W, this , 0);
- }
- else
- {
- for_obj.attach_dependent(interactor_consts.Y, this , 0);
- for_obj.attach_dependent(interactor_consts.H, this , 0);
- }
- break;
-
- case std_encoding_consts.PARTCODE_WH:
- if (horiz)
- for_obj.attach_dependent(interactor_consts.W, this , 0);
- else
- for_obj.attach_dependent(interactor_consts.H, this , 0);
- break;
- case std_encoding_consts.PARTCODE_VISIBLE:
- for_obj.attach_dependent(interactor_consts.VISIBLE, this , 0);
- break;
- case std_encoding_consts.PARTCODE_ENABLED:
- for_obj.attach_dependent(interactor_consts.ENABLED, this , 0);
- break;
- case std_encoding_consts.PARTCODE_PART_A:
- for_obj.attach_dependent(interactor_consts.PART_A, this , 0);
- break;
- case std_encoding_consts.PARTCODE_PART_B:
- for_obj.attach_dependent(interactor_consts.PART_B, this , 0);
- break;
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Setup dependencies for a particular operand. <p>
- *
- * @param byte op_std_part the part (or NOT_STANDARD)
- * @param interactor op_obj the object referred to for a non-standard part.
- * @param int op_part the part referred to for a non-standard part.
- */
- protected void setup_op_dependencies(
- byte op_std_part, interactor op_obj, int op_part)
- {
- /* do we a have a standard or non-standard part? */
- if (op_std_part != NOT_STANDARD)
- /* set up standard edges */
- setup_std_part_dependencies(op_obj, op_std_part);
- else
- /* set up single dependency to explicitly given part */
- op_obj.attach_dependent(op_part, this , 0);
-
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /** Establish the external dependencies needed for this constraint */
- protected void setup_dependencies()
- {
- Vector intrins;
-
- /* get dependencies that are intrinsic to the function being evaluated */
- intrins = std_constraint_impl.the_impl().implicit_depend_list(
- encoding(), self_obj(), orientation());
-
- /* walk down pairwise list of interactor/part and establish dependencies*/
- for (int i = 0; i < intrins.size(); i += 2)
- {
- setup_std_part_dependencies((interactor)intrins.elementAt(i),
- (byte)((Integer)intrins.elementAt(i+1)).intValue());
- }
-
- /* do operand dependencies */
- if (_num_ops > 0)
- setup_op_dependencies(op1_std_part(),op1_obj(),op1_part());
- if (_num_ops > 1)
- setup_op_dependencies(op2_std_part(),op2_obj(),op2_part());
- if (_num_ops > 2)
- setup_op_dependencies(op3_std_part(),op3_obj(),op3_part());
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Fetch a standard part from the given object. <p>
- *
- * @param interactor the_obj the object we are getting the part from.
- * @param int the_part encoding of the part (including IS_HORIZ bit).
- * @return int the value of the requested object part.
- */
- protected int fetch_std_part(interactor the_obj, int the_part)
- {
- boolean horiz;
- int code;
- int result;
- Point pt;
-
- horiz = (the_part & IS_HORIZ) != 0;
- code = the_part & ~IS_HORIZ;
-
- switch(code)
- {
- case std_encoding_consts.PARTCODE_XY:
- if (horiz)
- {
- /* get the value */
- result = the_obj.get_part(interactor_consts.X);
-
- /* put it in the coordinates of the parent of self */
- result = the_obj.x_into_local(result);
- pt = self_obj().global_to_local(
- the_obj.local_to_global(result,0));
- return self_obj().x_into_parent(pt.x);
- }
- else
- {
- /* get the value */
- result = the_obj.get_part(interactor_consts.Y);
-
- /* put it in the coordinates of the parent of self */
- result = the_obj.y_into_local(result);
- pt = self_obj().global_to_local(
- the_obj.local_to_global(0,result));
- return self_obj().y_into_parent(pt.y);
- }
-
- case std_encoding_consts.PARTCODE_WH:
- if (horiz)
- return the_obj.get_part(interactor_consts.W);
- else
- return the_obj.get_part(interactor_consts.H);
-
- case std_encoding_consts.PARTCODE_VISIBLE:
- return the_obj.get_part(interactor_consts.VISIBLE);
-
- case std_encoding_consts.PARTCODE_ENABLED:
- return the_obj.get_part(interactor_consts.ENABLED);
-
- case std_encoding_consts.PARTCODE_PART_A:
- return the_obj.get_part(interactor_consts.PART_A);
-
- case std_encoding_consts.PARTCODE_PART_B:
- return the_obj.get_part(interactor_consts.PART_B);
-
- case std_encoding_consts.PARTCODE_XY2:
- if (horiz)
- {
- /* get the value */
- result = the_obj.get_part(interactor_consts.X) +
- the_obj.get_part(interactor_consts.W);
-
- /* put it in the coordinates of the parent of self */
- result = the_obj.x_into_local(result);
- pt = self_obj().global_to_local(
- the_obj.local_to_global(result,0));
- return self_obj().x_into_parent(pt.x);
- }
- else
- {
- /* get the value */
- result = the_obj.get_part(interactor_consts.Y) +
- the_obj.get_part(interactor_consts.H);
-
- /* put it in the coordinates of the parent of self */
- result = the_obj.y_into_local(result);
- pt = self_obj().global_to_local(
- the_obj.local_to_global(0,result));
- return self_obj().y_into_parent(pt.y);
- }
-
- case std_encoding_consts.PARTCODE_CENTER:
- if (horiz)
- {
- /* get the value */
- result = the_obj.get_part(interactor_consts.X) +
- the_obj.get_part(interactor_consts.W)/2;
-
- /* put it in the coordinates of the parent of self */
- result = the_obj.x_into_local(result);
- pt = self_obj().global_to_local(
- the_obj.local_to_global(result,0));
- return self_obj().x_into_parent(pt.x);
- }
- else
- {
- /* get the value */
- result = the_obj.get_part(interactor_consts.Y) +
- the_obj.get_part(interactor_consts.H)/2;
-
- /* put it in the coordinates of the parent of self */
- result = the_obj.y_into_local(result);
- pt = self_obj().global_to_local(
- the_obj.local_to_global(0,result));
- return self_obj().y_into_parent(pt.y);
- }
-
- default:
- throw new sub_arctic_error("Unrecognized part code " + code +
- " found in std_ext_constraint.fetch_std_part()");
- }
- }
-
- //had:
- //* @exception bad_value if the_part is not a standard part code.
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Fetch a standard or non-standard part from the given interactor object. <p>
- *
- * @param interactor from_obj object we are getting part value from.
- * @param int std_part encoding for a standard part, or NOT_STANDARD.
- * @param int ext_part number of non-standard part being referred to.
- * @return int the value of the part.
- */
- protected int fetch_part(interactor from_obj, int std_part, int ext_part_num)
- {
- Object val;
-
- /* if we have no object use the fallback of a 0 value */
- if (from_obj == null) return 0;
-
- if (std_part != NOT_STANDARD)
- {
- /* get/compute the standard part */
- return fetch_std_part(from_obj, std_part);
- }
- else
- {
- /* get the non-standard part directly */
- val = from_obj.get_value(ext_part_num);
-
- /* make sure we got an integer */
- if (!(val instanceof Integer))
- throw new sub_arctic_error("Non-integer operand value found in "+
- "standard external constraint");
-
- return ((Integer)val).intValue();
- }
- }
-
- //had:
- //* @exception bad value if an improperly coded std_part or ext_part_num is
- //* found.
- //* @exception general
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Actually evaluate the constraint. Here the part number is ignored
- * since we only have one exported value. <p>
- *
- * @param int ignored_part_number Ignored.
- */
- public Object get_value(int ignored_part_number)
- {
- int result = 0;
- int val1 = 0;
- int val2 = 0;
- int val3 = 0;
-
- switch (_num_ops)
- {
- case 0:
- result = op0_impl.eval_fun(encoding(), self_obj(), const_value(),
- orientation());
- break;
- case 1:
- val1 = fetch_part(op1_obj(), op1_std_part(), op1_part());
- result = op1_impl.eval_fun(encoding(), self_obj(), val1,
- const_value(), orientation());
- break;
- case 2:
- val1 = fetch_part(op1_obj(), op1_std_part(), op1_part());
- val2 = fetch_part(op2_obj(), op2_std_part(), op2_part());
- result = op2_impl.eval_fun(encoding(), self_obj(), val1, val2,
- const_value(), orientation());
- break;
- case 3:
- val1 = fetch_part(op1_obj(), op1_std_part(), op1_part());
- val2 = fetch_part(op2_obj(), op2_std_part(), op2_part());
- val3 = fetch_part(op3_obj(), op3_std_part(), op3_part());
- result = op3_impl.eval_fun(encoding(), self_obj(), val1, val2,
- val3, const_value(), orientation());
- break;
- }
- return new Integer(result);
-
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-